1624C Division by Two and Permutation codeforces solution in cpp
by ujjal roy
#include<bits/stdc++.h>
using namespace std;
main()
{
int t,n,i,x;
cin>>t;
while(t--)
{
cin>>n;
vector<int> a(n+1);
for(i=0;i<n;i++)
{
cin>>x;
while(x>n||a[x])
{
x=x/2;
if(x==0) break;
}
a[x]++;
}
if(a[0]!=0) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
}
0 Comments